﻿// -----------------------------------------------------------------------
// <copyright file="BookSubscription.cs" company="EPAM Systems">
////Copyright (c) EPAM Systems, 2012. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace MBOP.Core.Entities.Library
{
	#region Usings

	using System;
	using System.ComponentModel.DataAnnotations.Schema;
	using System.Linq;

	#endregion

	/// <summary>
	/// BookSubscription's entity.
	/// </summary>
	[Table("BooksSubscriptions")]
	public partial class BookSubscription
	{
		#region Properties

		/// <summary>
		/// Gets or sets the book subscription id.
		/// </summary>
		public int ID { get; set; }

		/// <summary>
		/// Gets or sets the book id.
		/// </summary>
		public int BookID { get; set; }

		/// <summary>
		/// Gets or sets the book.
		/// </summary>
		public virtual Book Book { get; set; }

		/// <summary>
		/// Gets or sets the person's id.
		/// </summary>
		public string PersonID { get; set; }

		/// <summary>
		/// Gets or sets the subscription creation date.
		/// </summary>
		public DateTime Date { get; set; }

		/// <summary>
		/// Gets or sets the book subscription state.
		/// </summary>
		public int State { get; set; }

		/// <summary>
		/// Gets or sets the subscription set.
		/// </summary>
		public string SubscriptionSet { get; set; }

		/// <summary>
		/// Gets or sets the parentID
		/// </summary>
		public int? ParentID { get; set; }

		#endregion

		/// <summary>
		/// Gets the shallow copy of the current book subscription object.
		/// </summary>
		/// <returns>The shallow copy of the book subscription.</returns>
		public BookSubscription ShallowCopy()
		{
			var sourceProperties = this.GetType().GetProperties().Where(p => p.CanRead && p.CanWrite && !p.GetGetMethod().IsVirtual);

			BookSubscription newObj = new BookSubscription();

			foreach (var property in sourceProperties)
			{
				property.SetValue(newObj, property.GetValue(this, null), null);
			}

			return newObj;
		}
	}
}
